package disenio.tp.lucas;

import java.util.ArrayList;
import java.util.Collection;

public class test {

	public static void main(String[] args) throws Exception{
	
		SimpleParser isoSp = new SimpleParser("yyyy-MM-dd");
		UnifiedDate isoDate = new UnifiedDate("2011-11-08");
		isoDate.stringToDate(isoSp);
		
		SimpleParser latinoSp = new SimpleParser("dd/MM/yyyy");
		UnifiedDate latinoDate = new UnifiedDate("12/09/1996");
		latinoDate.stringToDate(latinoSp);
		
		SimpleParser usSp = new SimpleParser("MM-dd-yyyy");
		UnifiedDate usDate = new UnifiedDate("06-26-2008");
		usDate.stringToDate(usSp);
		
		Collection<DateParser> parsers = new ArrayList<DateParser>();
		parsers.add(isoSp);
		parsers.add(latinoSp);
		parsers.add(usSp);
		
		FlexibleParser flexFp = new FlexibleParser(parsers);
		UnifiedDate flexDateOk = new UnifiedDate("31/08/1995");
		flexDateOk.stringToDate(flexFp);
		
		long diffiso = isoDate.diasEntre(latinoDate);
		long difflatino = latinoDate.diasEntre(isoDate);
		
		UnifiedDate flexDateErr = new UnifiedDate("20011128");
		flexDateErr.stringToDate(flexFp);
		
		System.out.println("diferencia entre iso y latino: " + diffiso);
		System.out.println("diferencia entre latino e iso: " + difflatino);
		
		System.out.println("latino es anterior a iso: " + latinoDate.anteriorA(isoDate));
		System.out.println("iso es anterior a latino: " + isoDate.anteriorA(latinoDate));
		
		System.out.println("iso: " + isoDate.getFecha() + ".\nlatino: " + latinoDate.getFecha() + ".\nnorteamericano: " + 
				usDate.getFecha());
		
		System.out.println("flexible ok: " + flexDateOk.getFecha());
		
		System.out.println("flexible error: " + flexDateErr.getFecha());
		
	}
	
	
}
